//
//  DUHolidayView.swift
//  SimpleCal
//
//  Created by 杜晓祥 on 2021/11/3.
//

import Cocoa

@IBDesignable
class DUHolidayView: NSView {
    
    private var scrollView:NSScrollView!
    private var typeView:NSStackView!
    private var typeRadio = RadioButtonGroup<DUSubMenuButton>()
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        initialize()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        initialize()
    }
    
    override func layout() {
        self.layer?.backgroundColor = CGColor(red: 0.91, green: 0.91, blue: 0.91, alpha: 1)
        //typeView.layer?.backgroundColor = NSColor.lightGray.cgColor
    }
    
    private func initialize () {
        let w = self.frame.width
        let h = self.frame.height
        scrollView = NSScrollView(frame: NSRect(x: 0, y: 0, width: w, height: h))
        scrollView.drawsBackground = false
        scrollView.hasHorizontalScroller = false
        scrollView.hasVerticalScroller = true
        scrollView.autohidesScrollers = true
        scrollView.drawsBackground = false
        
        let d1 = DUClipView()
        d1.drawsBackground = false
        typeView = NSStackView(frame: NSRect(x: 0, y: 0, width: w, height: 60))
        typeView.orientation = .vertical
        typeView.alignment = .leading
        typeView.distribution = .fill
        typeView.spacing = 2
        
//        for n in (0...20) {
//            let b = DUSubMenuButton(frame: NSMakeRect(0, 0, 110, 30), withTitle: "测试\(n)")
//            b.setFixedConstraint(width: 110, height: 30)
//            typeRadio.addSubview(b)
//            typeView.addView(b, in: .leading)
//        }
        let b = wu()
        typeView.addView(b, in: .leading)
        d1.documentView = typeView
        scrollView.contentView = d1
        addSubview(scrollView)
    }
    
    
    
    private func wu() -> DULabel {
        let label = DULabel()
        label.frame = NSRect(x: 0, y: 0, width: self.frame.width, height: 30)
        label.cell = VerticallyCenteredTextFieldCell(textCell: "")
        label.font = NSFont.systemFont(ofSize: 16)
        label.textColor = NSColor(red: 0, green: 0, blue: 0, alpha: 0.9)
        label.backgroundColor = NSColor.gray
        label.alignment = .center
        label.stringValue = "暂无数据"
        return label
    }
    
    
}
